import os
import tkinter as tk
import webbrowser
from tkinter import ttk
from PIL import Image, ImageTk
import requests
from io import BytesIO
from tkhtmlview import HTMLLabel
from datetime import datetime, timedelta
from docx.shared import Pt, RGBColor
from tkinter import messagebox, filedialog
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
from reportlab.lib.units import inch
from docx import Document
import uuid
V=1.0
url="http://www.xiaotang.fun:8099/"
def get_images():
    try:
        response = requests.get(f"{url}/api/get_images")
        if response.status_code == 200:
            images = response.json().get('images', [])
            return images
        else:
            print("Failed to get images:", response.status_code)
            return response.status_code
    except Exception as e:
        print("Error occurred while getting images:", str(e))
        return str(e)

# 请求 /api/get_version_info
def get_version_info():
    try:
        response = requests.get(f"{url}/api/get_version_info")
        if response.status_code == 200:
            version_info = response.json().get('version_info', [])
            # print(version_info[0])
            return version_info[0]
        else:
            print("Failed to get version info:", response.status_code)
            return response.status_code
    except Exception as e:
        print("Error occurred while getting version info:", str(e))
        return str(e)
class Contracttab1:

    def __init__(self, root):
        self.root = root
        self.software_name_label = ttk.Label(self.root, text="软件名称:")
        self.software_name_label.grid(column=0, row=0, padx=10, pady=5)
        self.software_name_entry = ttk.Entry(self.root)
        self.software_name_entry.grid(column=1, row=0, padx=10, pady=5)

        self.version_label = ttk.Label(self.root, text="版本号:")
        self.version_label.grid(column=2, row=0, padx=10, pady=5)
        self.version_entry = ttk.Entry(self.root)
        self.version_entry.insert(0, "V1.0")
        self.version_entry.grid(column=3, row=0, padx=10, pady=5)

        self.add_button = ttk.Button(self.root, text="添加人员", command=self.add_contract)
        self.add_button.grid(column=4, row=0, padx=10, pady=5)

        self.contract_frame = ttk.Frame(self.root)
        self.contract_frame.grid(column=0, row=1, columnspan=5, padx=10, pady=10, sticky='nsew')
        self.contract_list = []
        self.alphabet = '甲乙丙丁戊己庚辛壬癸'


        for i in range(3):
            self.root.grid_columnconfigure(i, weight=1)
        # 获取今天的日期
        today = datetime.now()
        last_year = today - timedelta(days=365)
        formatted_date = last_year.strftime("%Y-%m-%d")
        self.date_label = ttk.Label(self.root, text="合同日期:")
        self.date_label.grid(column=0, row=2, padx=10, pady=5)
        self.date_entry = ttk.Entry(self.root)
        self.date_entry.grid(column=1, row=2, padx=10, pady=5)
        self.date_entry.insert(0, formatted_date)

        self.ps_label = ttk.Label(self.root, text="PS:合同日期提前一年，开发一年")
        self.ps_label.grid(column=2, row=2)


        self.sccompany_button = ttk.Button(self.root, text="生成模板", command=self.sccompany)
        self.sccompany_button.grid(column=4, row=2, padx=10, pady=5)
        self.sccompany1()

    def sccompany1(self):
        # 检查输入框内容是否为空
        if not self.software_name_entry.get().strip() or not self.version_entry.get().strip() or not self.date_entry.get().strip():
            # messagebox.showerror("213213")
            return

    def generate_agreement_document(self,software_name, version, contract_date, contract_list):
        try:
            # 获取用户选择的保存路径
            save_path = filedialog.askdirectory(title="选择保存位置")
            doc = Document()
            # 设置标题
            p = doc.add_paragraph()
            run = p.add_run("合作开发协议书")
            run.bold = True
            run.font.size = Pt(17)  # 设置字号
            p.alignment = 1  # 1 表示居中对齐
            for index, contract_item in enumerate(self.contract_list):
                name = contract_item['name_entry'].get().strip()
                id_number = contract_item['id_entry'].get().strip()
                paragraph = doc.add_paragraph(f"{self.alphabet[index]}方:{name} 身份证号码：{id_number}")
            doc.add_paragraph("注:开发人员顺序与著作权人顺序一致（由上至下）")
            # 添加段落和正文内容
            doc.add_paragraph("鉴于，协议各方均为计算机软件专业开发人员，能够进行创造性的软件开发活动。并且，协议各方有意愿共同从事 "
                              f"{software_name}（版本号：{version}）的开发工作。为了规范各方的权利义务，在《中华人民共和国合同法》及其他相关法规政策的原则指导下，订立本协议书，各方共同遵守：")

            p = doc.add_paragraph()
            run = p.add_run("第一条、合作宗旨")
            run.bold = True
            doc.add_paragraph("为完成 " + f"{software_name}（版本号：{version}）的开发工作，并共同享有开发成果而合作。")

            p = doc.add_paragraph()
            run = p.add_run("第二条、合作项目和范围")
            run.bold = True
            doc.add_paragraph("协议各方共同开发 " + f"{software_name}（版本号：{version}），合作范围包括软件的代码编写、调试、测试等开发工作。")

            p = doc.add_paragraph()
            run = p.add_run("第三条、合作期限")
            run.bold = True
            doc.add_paragraph("合作期限为一年。")

            p = doc.add_paragraph()
            run = p.add_run("第四条、合作方式")
            run.bold = True
            doc.add_paragraph("1. 协议各方按照软件编程工作的正常分工进行编写，任何一方不得随意更改软件的重大功能和事项，以免对其余各方造成履约困难。")
            doc.add_paragraph("2. 合作各方应坚持勤勉努力诚实信用的原则，进行各方分别负责的软件的编程工作，并考虑到各方软件的兼容和接口。如部分合作人发生特殊技术困难，其余合作方有义务为其提供合理适当的技术帮助。")

            p = doc.add_paragraph()
            run = p.add_run("第五条、知识产权")
            run.bold = True
            doc.add_paragraph("1. 各方编写的软件源代码、技术文档及汇编而成的程序本身，其著作权均由合作方共同享有。")
            doc.add_paragraph("2. 合作各方在编写软件的过程中，不得有侵犯他人知识产权的行为，否则，应对外承担全部侵权责任。")

            p = doc.add_paragraph()
            run = p.add_run("第六条、协议变更")
            run.bold = True
            doc.add_paragraph("1. 经合作各方协商同意，本协议可以作相应变更；")
            doc.add_paragraph("2. 任何合作方未经与其他各方协商，擅自变更本协议条款或者将本协议权利义务转让他人，均为无效。")

            p = doc.add_paragraph()
            run = p.add_run("第七条、禁止行为")
            run.bold = True
            doc.add_paragraph("1. 未经全体合作人同意，禁止任何合作人私自以团体名义进行业务活动；如其业务获得利益归合作各方共有，造成损失按实际损失赔偿。")
            doc.add_paragraph("2. 禁止合作人经营与团队相竞争的业务。")
            doc.add_paragraph("3. 禁止合作方泄露本协议所涉及的相关商业秘密。")
            doc.add_paragraph("4. 如合作人违反上述各条，应按实际损失赔偿。")

            p = doc.add_paragraph()
            run = p.add_run("第八条、合作的终止")
            run.bold = True
            doc.add_paragraph("合作开发活动因以下事由之一得终止：")
            doc.add_paragraph("① 全体合作人同意终止合作关系；")
            doc.add_paragraph("② 合作项目因技术原因，根本不能完成；")
            doc.add_paragraph("③ 合作项目违反法律被撤销。")

            p = doc.add_paragraph()
            run = p.add_run("第九条、纠纷的解决")
            run.bold = True
            doc.add_paragraph("合作各方之间如发生纠纷，应共同协商，本着有利于事业发展的原则予以解决。如协商不成，可以诉诸法院。")

            p = doc.add_paragraph()
            run = p.add_run("第十条、本协议如有未尽事宜，应由合作人集体讨论补充或修改。补充和修改的内容与本协议具有同等效力。")
            run.bold = True

            # 签署部分
            doc.add_paragraph("各方签署：")

            for index, contract_item in enumerate(self.contract_list):
                name = contract_item['name_entry'].get().strip()
                id_number = contract_item['id_entry'].get().strip()
                paragraph = doc.add_paragraph(f"{self.alphabet[index]}方:")

            p = doc.add_paragraph()
            p.alignment = 2  # 2 表示右对齐

            # 添加合同日期，向右居中
            run = p.add_run(contract_date)
            run.font.size = Pt(12)
            run.font.color.rgb = RGBColor(0, 0, 0)  # 设置为黑色
            # 生成一个随机的UUID
            random_uuid = uuid.uuid4()
            doc.save(save_path + "/" +f"合作开发协议书{random_uuid}.docx")
            messagebox.showinfo("成功", "保存至"+save_path)
        except Exception as e:
            print(e)
            messagebox.showerror("错误", "生成失败"+str(e))

    def sccompany(self):
        # 检查输入框内容是否为空
        if not self.software_name_entry.get().strip() or not self.version_entry.get().strip() or not self.date_entry.get().strip():
            messagebox.showerror("错误", "输入框中的内容不能为空")
            return

        # 打印软件名称、版本号和合同日期
        software_name = self.software_name_entry.get().strip()
        version = self.version_entry.get().strip()
        contract_date = self.date_entry.get().strip()

        # 打印合同列表中的内容
        for index, contract_item in enumerate(self.contract_list):
            name = contract_item['name_entry'].get().strip()
            id_number = contract_item['id_entry'].get().strip()
            if len(id_number) != 18:
                messagebox.showerror("写入失败", f"{self.alphabet[index]}方 - 身份证号应为18位")
                return
        # 新建文档对象按模板新建 word 文档文件，具有模板文件的所有格式
        self.generate_agreement_document(software_name, version, contract_date, self.contract_list)

    def add_contract(self):
        if len(self.contract_list) >= len(self.alphabet):
            messagebox.showerror("错误", "超过最大用户数")
            return

        row = len(self.contract_list) + 1
        seq_label = ttk.Label(self.contract_frame, text=self.alphabet[len(self.contract_list)] + "方")
        seq_label.grid(column=0, row=row, padx=10, pady=5)

        name_label = ttk.Label(self.contract_frame, text="姓名:")
        name_label.grid(column=1, row=row, padx=10, pady=5)
        name_entry = ttk.Entry(self.contract_frame)
        name_entry.grid(column=2, row=row, padx=10, pady=5)
        if self.alphabet[len(self.contract_list)] == "甲":
            name_entry.insert(0, "人员顺序同软著位置一致")

        id_label = ttk.Label(self.contract_frame, text="身份证:")
        id_label.grid(column=3, row=row, padx=10, pady=5)
        id_entry = ttk.Entry(self.contract_frame)
        id_entry.grid(column=4, row=row, padx=10, pady=5)

        delete_button = ttk.Button(self.contract_frame, text="删除",
                                   command=lambda seq=name_entry: self.delete_contract(seq))
        delete_button.grid(column=5, row=row, padx=10, pady=5)

        # 将合同条目存储为字典，并添加到合同列表中
        contract_item = {'seq_label': seq_label, 'name_label': name_label, 'name_entry': name_entry,
                         'id_label': id_label, 'id_entry': id_entry, 'delete_button': delete_button}
        self.contract_list.append(contract_item)

    def delete_contract(self, name_entry):
        # 获取要删除的合同条目在列表中的索引
        index_to_delete = None
        for index, item in enumerate(self.contract_list):
            if item['name_entry'] == name_entry:
                index_to_delete = index
                break

        if index_to_delete is not None:
            # 获取要删除的合同条目的信息
            contract_to_delete = self.contract_list[index_to_delete]

            # 从界面上删除对应的部件
            contract_to_delete['seq_label'].grid_forget()
            contract_to_delete['name_label'].grid_forget()
            contract_to_delete['name_entry'].grid_forget()
            contract_to_delete['id_label'].grid_forget()
            contract_to_delete['id_entry'].grid_forget()
            contract_to_delete['delete_button'].grid_forget()

            # 更新合同列表和界面上剩余条目的序号
            self.contract_list.pop(index_to_delete)
            self.update_contract_sequence()
            self.relayout_contract_items()

    def update_contract_sequence(self):
        # 更新剩余合同条目的序号
        for index, contract_item in enumerate(self.contract_list):
            contract_item['seq_label'].config(text=self.alphabet[index] + "方")

    def relayout_contract_items(self):
        # 重新布局合同条目，确保顺序正确
        for index, contract_item in enumerate(self.contract_list):
            contract_item['seq_label'].grid(row=index + 1, column=0, padx=10, pady=5)
            contract_item['name_label'].grid(row=index + 1, column=1, padx=10, pady=5)
            contract_item['name_entry'].grid(row=index + 1, column=2, padx=10, pady=5)
            contract_item['id_label'].grid(row=index + 1, column=3, padx=10, pady=5)
            contract_item['id_entry'].grid(row=index + 1, column=4, padx=10, pady=5)
            contract_item['delete_button'].grid(row=index + 1, column=5, padx=10, pady=5)
class Contracttab2:

    def __init__(self, root):
        self.root = root
        self.directory_path = ''
        # 文件夹路径标签和输入框
        self.directory_label = ttk.Label(self.root, text="文件夹路径：")
        self.directory_label.grid(column=0, row=0, padx=10, pady=5)
        self.directory_entry = ttk.Entry(self.root, width=40)  # 调整输入框宽度为40
        self.directory_entry.grid(column=1, row=0, padx=10, pady=5)

        # 选择文件夹按钮
        self.select_button = ttk.Button(self.root, text="选择文件夹", command=self.select_directory)
        self.select_button.grid(column=2, row=0, padx=10, pady=5)

        # 文件类型标签和输入框
        self.file_type_label = ttk.Label(self.root, text="文件类型（可选,以英文分号分隔 格式: java;cpp;xml）：")
        self.file_type_label.grid(column=0, row=1, padx=10, pady=5)
        self.file_type_entry = ttk.Entry(self.root, width=40)  # 调整输入框宽度为40
        self.file_type_entry.grid(column=1, row=1, padx=10, pady=5)

        # 搜索按钮
        self.search_button = ttk.Button(self.root, text="过滤", command=self.search_files)
        self.search_button.grid(column=2, row=1, padx=10, pady=5)

        # 文件列表框
        self.files_listbox = tk.Listbox(self.root, width=70)
        self.files_listbox.grid(column=0, row=2, columnspan=3, padx=10, pady=10, sticky='nsew')

        # 创建一个框架来包含两个按钮
        self.button_frame = ttk.Frame(self.root)
        self.button_frame.grid(column=0, row=3, columnspan=3, padx=10, pady=5)

        # 写入按钮 - 写入txt
        self.write_txt_button = ttk.Button(self.button_frame, text="全部写入txt", command=self.write_to_txt)
        self.write_txt_button.pack(side=tk.LEFT, padx=5)

        # 写入按钮 - 生成Word
        self.write_word_button = ttk.Button(self.button_frame, text="直接生成60页word", command=self.generate_pdf)
        self.write_word_button.pack(side=tk.LEFT, padx=5)

        # 文件数量标签
        self.file_count_label = ttk.Label(self.root, text="共计搜索到 0 个文件")
        self.file_count_label.grid(column=0, row=4, columnspan=3, padx=10, pady=5, sticky='se')  # 放置在右下角

        # 设置网格布局权重，使得窗口大小变化时文件列表框能够自适应
        self.root.grid_columnconfigure(0, weight=1)
        self.root.grid_columnconfigure(1, weight=1)
        self.root.grid_columnconfigure(2, weight=1)
        self.root.grid_rowconfigure(2, weight=1)

    def generate_pdf(self):
        directory = self.directory_entry.get()
        if not directory:
            messagebox.showerror("错误", "未选择文件路径！")
            return

        save_path = filedialog.asksaveasfilename(defaultextension=".pdf", filetypes=[("PDF files", "*.pdf")])
        if not save_path:
            return  # 用户取消保存操作

        try:
            c = canvas.Canvas(save_path, pagesize=A4)
            width, height = A4
            pdfmetrics.registerFont(TTFont('SimSun', 'simsun.ttc'))  # 确保simsun.ttf在你的环境中可用

            # # 第一页：插入标题 "源程序"，初号字体，居中
            c.setFont("SimSun", 42)
            c.drawCentredString(width / 2.0, height / 2.0, "源程序")
            c.showPage()  # 结束第一页

            # 第二页开始：按要求写入文件内容
            content_index = 0
            lines_per_page = 60  # 每页大约50行
            max_pages = 60
            current_page = 1

            while content_index < self.files_listbox.size() and current_page <= max_pages:
                y_position = height - inch  # 初始位置
                c.setFont("SimSun", 8)

                for _ in range(lines_per_page):
                    if content_index < self.files_listbox.size():
                        file_path = os.path.join(directory, self.files_listbox.get(content_index))
                        with open(file_path, 'r', encoding='utf-8') as f:
                            content = f.read()
                            for line in content.splitlines():
                                if y_position < inch:  # 移动到底部边界
                                    break
                                # 如果线超出页面宽度，则换行
                                text_width = width - 2 * inch
                                wrapped_lines = self.wrap_text(line, text_width, c)
                                for wline in wrapped_lines:
                                    c.drawString(inch, y_position, wline)
                                    y_position -= 12
                                    if y_position < inch:
                                        break
                            content_index += 1
                        if y_position < inch:
                            break

                # 添加页码
                if current_page >= 1:
                    c.setFont("Times-Roman", 12)
                    c.drawCentredString(width / 2.0, 0.75 * inch, str(current_page))

                c.showPage()  # 结束当前页
                current_page += 1

            # 保存文档
            c.save()
            messagebox.showinfo("成功", "生成PDF文档成功！")
        except Exception as e:
            print(e)
            messagebox.showerror("错误", str(e) + "请检查有无图片视频等无法读取元素或文件被打开")

    def wrap_text(self,text, max_width, canvas):
        """将文本按给定宽度进行换行"""
        words = text.split(' ')
        lines = []
        current_line = ""
        for word in words:
            if canvas.stringWidth(current_line + word, 'SimSun', 10) < max_width:
                current_line += (word + ' ')
            else:
                lines.append(current_line.strip())
                current_line = word + ' '
        lines.append(current_line.strip())  # 最后一行
        return lines

    def search_files(self):
        self.files_listbox.delete(0, tk.END)

        if not self.directory_path:
            messagebox.showerror("错误", "请选择文件夹路径！")
            return

        file_types = self.file_type_entry.get().split(';')

        if len(file_types) == 1 and file_types[0] == '':
            file_types = None
        file_count = 0
        for root, dirs, files in os.walk(self.directory_path):
            for file in files:
                if file_types is None or file.lower().endswith(tuple(file_types)):
                    file_count += 1
                    file_path = os.path.join(root, file)
                    relative_path = os.path.relpath(file_path, self.directory_path)
                    self.files_listbox.insert(tk.END, relative_path)

        # 更新文件数量标签
        self.file_count_label.config(text=f"共计搜索到 {file_count} 个文件")
    def select_directory(self):
        self.directory_path = filedialog.askdirectory()
        self.directory_entry.delete(0, tk.END)
        self.directory_entry.insert(0, self.directory_path)
        self.search_files()

    def write_to_txt(self):
        directory = self.directory_entry.get()
        if not directory:
            messagebox.showerror("错误", "没有找到文件路径！")
            return

        save_path = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files", "*.txt")])
        if not save_path:
            messagebox.showerror("错误", "请选择保存文件路径！")
            return
        try:
            with open(save_path, 'w', encoding='utf-8') as output_file:
                for i in range(self.files_listbox.size()):
                    file_path = os.path.join(self.directory_path, self.files_listbox.get(i))
                    with open(file_path, 'r', encoding='utf-8') as f:
                        content = f.readlines()  # 按行读取文件内容
                        content = [line.strip() for line in content if line.strip()]  # 去除空行
                        if content:
                            output_file.write(f'File: {file_path}\n')
                            output_file.write('\n'.join(content) + '\n\n')
            messagebox.showinfo("成功", "写入成功！")
        except Exception as e:
            print(e)
            messagebox.showerror("错误", str(e) + "请检查有无图片视频等无法读取元素")


def panduan(version_info):
    if str(version_info[0]) == str(V):
        # messagebox.showinfo("目前为最新版本:" + str(V), "V:" + str(V))
        print(2)  # 这里可能是你的调试信息，可以根据需要修改
    else:
        # 执行更新操作
        update_url = version_info[1]
        answer = messagebox.showinfo("新版本更新",f"最新版本已经更新为(V:{version_info[0]})前往下载新版本")
        webbrowser.open_new_tab(update_url)
    root.mainloop()
if __name__ == "__main__":

    root = tk.Tk()
    root.title("软快著 v1.0")
    root.geometry("700x500")
    root.resizable(False, False)
    version_info=get_version_info()
    notebook = ttk.Notebook(root)
    tab0 = ttk.Frame(notebook)
    tab1 = ttk.Frame(notebook)
    tab2 = ttk.Frame(notebook)
    tab3 = ttk.Frame(notebook)
    tab4 = ttk.Frame(notebook)
    notebook.add(tab0, text='注册流程')
    notebook.add(tab1, text='开发合同模板(仅合作开发需要)')
    notebook.add(tab2, text='代码读取')
    notebook.add(tab3, text='其他模板')
    notebook.add(tab4, text='联系小唐')
    notebook.pack(expand=1, fill="both")

    # 注册流程界面
    html_content = """
    <!doctype html>
    <html>
    <body><h2>注册流程</h2>
    <p></p>
    <p><a href='https://www.bilibili.com/video/BV1Zx4y1H7xA/?share_source=copy_web&vd_source=aefaa07ad13caa929a19dcec021efc8b'>详细可查看【10分钟搞懂软著申请 带模版 全流程演示】</a></p>
    <h3>1.首先我们需要在中国版权保护中心注册账户</h3>
    <p><a href='https://register.ccopyright.com.cn/login.html'>登录 (ccopyright.com.cn)</a></p>
    <p><img src="https://img.js.design/assets/img/66719ea7f7399746d9b399a8.png#94ab18f398abe4e58b11e805c843f4f3);" alt="网络未连接" style="zoom:33%;" /></p>
    <h4>2.身份认证</h4>
    <p>注意不要从用户的认证进入会闪退</p>
    <p>请直接从下方网站进入后，直接点击<strong>立刻登记</strong></p>
    <p><a href='https://register.ccopyright.com.cn/registration.html#/registerSoft'>中国版权登记业务平台 (ccopyright.com.cn)</a></p>
    <p></p>
    <p><img src="https://img.js.design/assets/img/66719f1e80fab90fe6d97e26.png#242ae11fbb9a4323eede1c7900d87436);" alt="image-网络未连接" style="zoom:33%;" /></p>
    <p>需要手持身份证拍照和提交身份证正反面</p>
    <p><strong>注意不要镜像和模糊会审核不通过</strong></p>
    <p><strong>注意不要镜像和模糊会审核不通过</strong></p>
    <p><strong>注意不要镜像和模糊会审核不通过</strong></p>
    <p>审核周期为 1 天左右，周末节假日不会上班</p>
    <p>认证之后在账号管理的实名认证界面会出现你的结果</p>
    <p><img src="https://img.js.design/assets/img/66719f1e4c41972feeaa2807.png#2017428f418634a5226e6954cbf7d9cd);" alt="网络未连接" style="zoom:33%;" /></p>
    </body>
    </html>
    """
    html_label = HTMLLabel(tab0, html=html_content)
    html_label.pack(fill="both", expand=True)


    # 开发合同界面
    contract_tab1 = Contracttab1(tab1)

    # 代码读取
    contract_tab2 = Contracttab2(tab2)

    # 开发文档
    label3 = tk.Label(tab3, text='开发文档可以交你平时的课程设计，如果没有课程设计的同学，需要写一个软件说明书,模板如上\n软硬件配置也可以参考我的找个，按照自己的机型来写就ok了')
    html_content = """
    <!doctype html>
    <html>
    <h3><a href='https://kdocs.cn/l/cfgAF7VJztvs'>软件说明书.doc</h3></p>
    <h3><a href='https://kdocs.cn/l/ceXOhUxZXQRO'>硬件配置.pdf</h3></p>
    </body>
    </html>
    """
    html_label = HTMLLabel(tab3, html=html_content)
    html_label.pack(fill="both", expand=True)
    label3.pack(padx=10, pady=10)

    # 联系小唐界面内容
    label4 = tk.Label(tab4,
                      text='欢迎随时联系小唐！\n无论是bug还是其他问题，有偿接单ing\nps：我看过合格的代码我可以帮你免费申请\nQQ：1019167666\n软件完全免费,如果你是花钱买到的说明被骗了\n本软件已申请软著，欢迎举报！\n因为接受不了淘宝申请的溢价，所以开源\n开源不易，救救孩子')
    label4.pack(padx=10, pady=5)
    # 加载并显示图片
    def load_image(url, size):
        response = requests.get(url)
        img_data = response.content
        img = Image.open(BytesIO(img_data))
        img = img.resize(size, Image.LANCZOS)
        return ImageTk.PhotoImage(img)


    image_urls = [
        "https://img.js.design/assets/img/66712e380888c830c1d222fc.jpg",
        "https://img.js.design/assets/img/66712e3e877ef45f17a8d751.jpg",
        "https://img.js.design/assets/img/66712e55853c7516d38fdf79.jpg"
    ]

    image_size = (230, 270)
    images = [load_image(url, image_size) for url in image_urls]
    frame = ttk.Frame(tab4)
    frame.pack(pady=10)
    for img in images:
        label = ttk.Label(frame, image=img)
        label.pack(side="left", padx=5)
    panduan(version_info)
    root.mainloop()

